rainmaker simple project

115

    /* Initialize Wi-Fi. Note that, this should be called before esp_rmaker_init()
     */
    app_wifi_init();

    /* Initialize the ESP RainMaker Agent.
     * Note that this should be called after app_wifi_init() but before app_wifi_start()
     * */
    esp_rmaker_config_t rainmaker_cfg = {
        .enable_time_sync = false,
    };
    esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Device", "Switch");
    if (!node) {
        ESP_LOGE(TAG, "Could not initialise node. Aborting!!!");
        vTaskDelay(5000/portTICK_PERIOD_MS);
        abort();
    }

    /* Create a Switch device.
     * You can optionally use the helper API esp_rmaker_switch_device_create() to
     * avoid writing code for adding the name and power parameters.
     */
    switch_device = esp_rmaker_device_create("Switch", ESP_RMAKER_DEVICE_SWITCH, NULL);

    /* Add the write callback for the device. We aren't registering any read callback yet as
     * it is for future use.
     */
    esp_rmaker_device_add_cb(switch_device, write_cb, NULL);

    /* Add the standard name parameter (type: esp.param.name), which allows setting a persistent,
     * user friendly custom name from the phone apps. All devices are recommended to have this
     * parameter.
     */
    esp_rmaker_device_add_param(switch_device, esp_rmaker_name_param_create("name", "Switch"));

    /* Add the standard power parameter (type: esp.param.power), which adds a boolean param
     * with a toggle switch ui-type.
     */
    esp_rmaker_param_t *power_param = esp_rmaker_power_param_create("power", DEFAULT_POWER);
    esp_rmaker_device_add_param(switch_device, power_param);

    /* Assign the power parameter as the primary, so that it can be controlled from the
     * home screen of the phone apps.
     */
    esp_rmaker_device_assign_primary_param(switch_device, power_param);

    /* Add this switch device to the node */
    esp_rmaker_node_add_device(node, switch_device);

    /* Start the ESP RainMaker Agent */
    esp_rmaker_start();

    /* Start the Wi-Fi.
     * If the node is provisioned, it will start connection attempts,
     * else, it will start Wi-Fi provisioning. The function will return
     * after a connection has been successfully established
     */
    app_wifi_start(POP_TYPE_RANDOM);

Comments

Submit
0 Comments

More Questions

boolean in crandom number c ModuleNotFoundError: No module named cv2
check dns server in linuxread files in c how to get user input in c
print boolean value in clatex font sizes see if two strings are equal in C
how to download file in powershellprintf with bool invoke-webrequest download file
write in file in cmongodb delete all documents how to genrate a random number in C
how to print boolean in csleep in c programming install zoom on ubuntu
c concatenate stringstake array as input in c install gitk mac
remove element from np arrayprint an array in c C static libraries (creating object files)
exponentials in cC++ initalize int16_t value script hack blox fruti
pointer operatorcheck command line input is a number in c what is covert channel
sqlserver insert with set identity-usr-bin-env: python-r: No such file or directory linear search program in c
Uri-beecrowd problem no - 1099 solution in Cc addition The fscanf and fprintf functions
function that reverses the content of an array of integers.how to search in a file in c Couldnt create temporary file to work with
WARNING: QA Issue: bgslibrary-dev rdepends on libopencv-imgproc, but it isnt a build dependency, missing opencv in DEPENDS or PACKAGECONFIG [build-deps]reading arrays from stdin c add a item to cart woocomerce with quantity
Using PostgreSQL array to store many-to-many relationship using sqlalchemylistas enlazadas- linked lists binary sorting
c how to include variables of other c filec strcat uri-beecrowd problem no - 1133 solution in C